<script>
$(function() {
	$( "#tabs" ).tabs({
	    select: function(event, ui) {
	        var url = $.data(ui.tab, 'load.tabs');
	        if( url ) {
	            location.href = url;
	            return false;
	        }
	        return true;
	    },
	selected: 2 
	});
});
</script>
<div id="tabs">
	<ul>
    <li><?php echo $this->Html->link(__('Danh sách quyền', true), array('controller'=>'roles','action' => 'index')); ?></li>
    <li><?php echo $this->Html->link(__('Danh sách chức vụ', true), array('controller'=>'phanquyens','action' => 'phanquyenchucd')); ?></li>
     <li><a href='#accordion'>Danh sách chi đoàn</a> </li>
	</ul>
<div id='accordion'>
<h3><a href="#">Danh sách đoàn viên</a></h3>
<div>
<?php echo $form->create('Phanquyen',array());?>
<table>
<tr>
<td><?php echo $form->input('loaidv',array('id'=>'loaidv','label'=>'Loại user','type'=>'select','options'=>array(0=>'Sinh viên',1=>'Cán bộ'),'selected'=>0));?></td>
<td><div id='div_chidoan'><?php echo $form->input('chidoan',array('id'=>'chidoan','label'=>'Chi đoàn','type'=>'select','options'=>$chidoans,'empty'=>'-- Chọn chi đoàn --'));?></div></td>
</tr>
</table>
<div id='table_ds'>
<table id='tables'>
<tr>
<th>STT</th>
<th>Họ tên</th>
<th>Chức vụ</th>
<?php foreach ($quyens as $quyen_id=>$quyenval):?>
<th><?php echo $quyenval;?></th>
<?php endforeach;?>
</tr>
</table>
</div>
<?php $this->Js->get('#loaidv')->event('change',
							$this->Js->request(array('controller' => 'phanquyens', 'action' => 'updatecd'),
							array('update' => '#div_chidoan','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>

<?php $this->Js->get('#loaidv')->event('change',
							$this->Js->request(array('controller' => 'phanquyens', 'action' => 'updateds'),
							array('update' => '#table_ds','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>
<?php $this->Js->get('#div_chidoan')->event('change',
							$this->Js->request(array('controller' => 'phanquyens', 'action' => 'updateds'),
							array('update' => '#table_ds','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>
<?php echo $form->end();?>
</div>
<h3><a href="#">Thêm - Xóa quyền</a></h3>
<div style="height: 700px;">
<h2>Phân Quyền</h2>
<?php echo $form->create('Phanquyen',array('url'=>array('controller'=>'phanquyens','action'=>'phanquyencd')));?>
<table>
<tr>
<td><?php echo $form->input('loaidvpq',array('id'=>'loaidvpq','label'=>'Loại user','type'=>'select','options'=>array(0=>'Sinh viên',1=>'Cán bộ'),'selected'=>0));?></td>
<td><div id='div_chidoanpq'><?php echo $form->input('chidoanpq',array('id'=>'chidoanpq','label'=>'Chi đoàn','type'=>'select','options'=>$chidoans,'empty'=>'-- Chọn chi đoàn --'));?></div></td>
</tr>
</table>
<div id='div_phanquyen'>
<table>
</table>
</div>
<?php $this->Js->get('#loaidvpq')->event('change',
							$this->Js->request(array('controller' => 'phanquyens', 'action' => 'updatecd'),
							array('update' => '#div_chidoanpq','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>
<?php $this->Js->get('#loaidvpq')->event('change',
							$this->Js->request(array('controller' => 'phanquyens', 'action' => 'updatedspquyen'),
							array('update' => '#div_phanquyen','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>
<?php $this->Js->get('#div_chidoanpq')->event('change',
							$this->Js->request(array('controller' => 'phanquyens', 'action' => 'updatedspquyen'),
							array('update' => '#div_phanquyen','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>
<?php echo $form->end('Lưu');?>
</div>
</div>
<script type="text/javascript">
<!--
$(function(){
	$( "#accordion" ).accordion({
		autoHeight: false,
		navigation: true
								});
	$('.checkall').live('click',function(){
			if($(this).prop('checked')==true)
			{
				id=$(this).prop('id');
				$('.check_'+id).prop('checked',true);
			}else
			{
				id=$(this).prop('id');
				$('.check_'+id).prop('checked',false);
			}
		});
});
</script>